<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Participant extends Application_Model_ModelAbstract
{

    /**
     * Database var type varchar(8)
     *
     * @var string
     */
    protected $_Cin;

    /**
     * Database var type varchar(30)
     *
     * @var string
     */
    protected $_Nom;

    /**
     * Database var type varchar(30)
     *
     * @var string
     */
    protected $_Prenom;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DateDeNaissance;

    /**
     * Database var type varchar(100)
     *
     * @var string
     */
    protected $_Adresse;

    /**
     * Database var type int(15)
     *
     * @var int
     */
    protected $_Telephone;

    /**
     * Database var type varchar(30)
     *
     * @var string
     */
    protected $_Email;

    /**
     * Database var type varchar(30)
     *
     * @var string
     */
    protected $_Login;

    /**
     * Database var type varchar(20)
     *
     * @var string
     */
    protected $_Password;

    /**
     * Database var type int(3)
     *
     * @var int
     */
    protected $_EtablissementIdEtab;

    /**
     * Database var type int(2)
     *
     * @var int
     */
    protected $_RoleIdRole;


    /**
     * Parent relation fk_participant_etablissement1
     *
     * @var Application_Model_Etablissement
     */
    protected $_Etablissement;

    /**
     * Parent relation fk_participant_role1
     *
     * @var Application_Model_Role
     */
    protected $_Role;


    /**
     * Dependent relation fk_sessionformation_has_participant_participant1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_SessionformationHasParticipant
     */
    protected $_SessionformationHasParticipant;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'cin'=>'Cin',
            'nom'=>'Nom',
            'prenom'=>'Prenom',
            'date_de_naissance'=>'DateDeNaissance',
            'adresse'=>'Adresse',
            'telephone'=>'Telephone',
            'email'=>'Email',
            'login'=>'Login',
            'password'=>'Password',
            'etablissement_id_etab'=>'EtablissementIdEtab',
            'role_id_role'=>'RoleIdRole',
        ));

        $this->setParentList(array(
            'FkParticipantEtablissement1'=> array(
                    'property' => 'Etablissement',
                    'table_name' => 'Etablissement',
                ),
            'FkParticipantRole1'=> array(
                    'property' => 'Role',
                    'table_name' => 'Role',
                ),
        ));

        $this->setDependentList(array(
            'FkSessionformationHasParticipantParticipant1' => array(
                    'property' => 'SessionformationHasParticipant',
                    'table_name' => 'SessionformationHasParticipant',
                ),
        ));
    }

    /**
     * Sets column cin
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setCin($data)
    {
        $this->_Cin = $data;
        return $this;
    }

    /**
     * Gets column cin
     *
     * @return string
     */
    public function getCin()
    {
        return $this->_Cin;
    }

    /**
     * Sets column nom
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setNom($data)
    {
        $this->_Nom = $data;
        return $this;
    }

    /**
     * Gets column nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->_Nom;
    }

    /**
     * Sets column prenom
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setPrenom($data)
    {
        $this->_Prenom = $data;
        return $this;
    }

    /**
     * Gets column prenom
     *
     * @return string
     */
    public function getPrenom()
    {
        return $this->_Prenom;
    }

    /**
     * Sets column date_de_naissance
     *
     * @param date $data
     * @return Application_Model_Participant
     */
    public function setDateDeNaissance($data)
    {
        $this->_DateDeNaissance = $data;
        return $this;
    }

    /**
     * Gets column date_de_naissance
     *
     * @return date
     */
    public function getDateDeNaissance()
    {
        return $this->_DateDeNaissance;
    }

    /**
     * Sets column adresse
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setAdresse($data)
    {
        $this->_Adresse = $data;
        return $this;
    }

    /**
     * Gets column adresse
     *
     * @return string
     */
    public function getAdresse()
    {
        return $this->_Adresse;
    }

    /**
     * Sets column telephone
     *
     * @param int $data
     * @return Application_Model_Participant
     */
    public function setTelephone($data)
    {
        $this->_Telephone = $data;
        return $this;
    }

    /**
     * Gets column telephone
     *
     * @return int
     */
    public function getTelephone()
    {
        return $this->_Telephone;
    }

    /**
     * Sets column email
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setEmail($data)
    {
        $this->_Email = $data;
        return $this;
    }

    /**
     * Gets column email
     *
     * @return string
     */
    public function getEmail()
    {
        return $this->_Email;
    }

    /**
     * Sets column login
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setLogin($data)
    {
        $this->_Login = $data;
        return $this;
    }

    /**
     * Gets column login
     *
     * @return string
     */
    public function getLogin()
    {
        return $this->_Login;
    }

    /**
     * Sets column password
     *
     * @param string $data
     * @return Application_Model_Participant
     */
    public function setPassword($data)
    {
        $this->_Password = $data;
        return $this;
    }

    /**
     * Gets column password
     *
     * @return string
     */
    public function getPassword()
    {
        return $this->_Password;
    }

    /**
     * Sets column etablissement_id_etab
     *
     * @param int $data
     * @return Application_Model_Participant
     */
    public function setEtablissementIdEtab($data)
    {
        $this->_EtablissementIdEtab = $data;
        return $this;
    }

    /**
     * Gets column etablissement_id_etab
     *
     * @return int
     */
    public function getEtablissementIdEtab()
    {
        return $this->_EtablissementIdEtab;
    }

    /**
     * Sets column role_id_role
     *
     * @param int $data
     * @return Application_Model_Participant
     */
    public function setRoleIdRole($data)
    {
        $this->_RoleIdRole = $data;
        return $this;
    }

    /**
     * Gets column role_id_role
     *
     * @return int
     */
    public function getRoleIdRole()
    {
        return $this->_RoleIdRole;
    }

    /**
     * Sets parent relation EtablissementIdEtab
     *
     * @param Application_Model_Etablissement $data
     * @return Application_Model_Participant
     */
    public function setEtablissement(Application_Model_Etablissement $data)
    {
        $this->_Etablissement = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_etab'];
        }

        $this->setEtablissementIdEtab($primary_key);

        return $this;
    }

    /**
     * Gets parent EtablissementIdEtab
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Etablissement
     */
    public function getEtablissement($load = true)
    {
        if ($this->_Etablissement === null && $load) {
            $this->getMapper()->loadRelated('FkParticipantEtablissement1', $this);
        }

        return $this->_Etablissement;
    }

    /**
     * Sets parent relation RoleIdRole
     *
     * @param Application_Model_Role $data
     * @return Application_Model_Participant
     */
    public function setRole(Application_Model_Role $data)
    {
        $this->_Role = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_role'];
        }

        $this->setRoleIdRole($primary_key);

        return $this;
    }

    /**
     * Gets parent RoleIdRole
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Role
     */
    public function getRole($load = true)
    {
        if ($this->_Role === null && $load) {
            $this->getMapper()->loadRelated('FkParticipantRole1', $this);
        }

        return $this->_Role;
    }

    /**
     * Sets dependent relations fk_sessionformation_has_participant_participant1
     *
     * @param array $data An array of Application_Model_SessionformationHasParticipant
     * @return Application_Model_Participant
     */
    public function setSessionformationHasParticipant(array $data)
    {
        $this->_SessionformationHasParticipant = array();

        foreach ($data as $object) {
            $this->addSessionformationHasParticipant($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_sessionformation_has_participant_participant1
     *
     * @param Application_Model_SessionformationHasParticipant $data
     * @return Application_Model_Participant
     */
    public function addSessionformationHasParticipant(Application_Model_SessionformationHasParticipant $data)
    {
        $this->_SessionformationHasParticipant[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_sessionformation_has_participant_participant1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_SessionformationHasParticipant
     */
    public function getSessionformationHasParticipant($load = true)
    {
        if ($this->_SessionformationHasParticipant === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationHasParticipantParticipant1', $this);
        }

        return $this->_SessionformationHasParticipant;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Participant
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Participant());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Participant::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getCin() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('cin = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getCin()));
    }
}
